package com.zjyd.douyanglive.controller;

import com.zjyd.douyangcommoncore.result.Result;
import com.zjyd.douyanglive.service.ILiveService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 直播接口
 */
@Slf4j
@RestController
@Tag(name = "直播业务")
@RequestMapping("/douyang/live")
//监听配置中心的配置文件是否被修改
@RefreshScope
public class LiveController {

    @Autowired
    private ILiveService iLiveService;

    //控制是否打开直播
    //加:可以设置默认值（非必填）
    @Value("${live.isOpenLive:true}")
    private boolean isOpenLive;

    @Operation(summary = "获取直播列表")
    @GetMapping("/getLiveList")
    public Result getLiveList(){
        if(isOpenLive){
            return Result.success("这是直播间列表");
        }else{
            return Result.error("直播平台整改中");
        }
    }

    /**
     * 直播打赏接口
     */
    @GetMapping("/LiveTip")
    public String liveTip(){
        log.info("1、请求的进入");
        String s = iLiveService.liveTip(101);
        return s;
    }

}
